cmake_minimum_required (VERSION 2.6)
project (codegen)
# The version number.
set (CODEGEN_VERSION_MAJOR 0)
set (CODEGEN_VERSION_MINOR 1)
set (CODEGEN_VERSION_PATCH 0)
set (CODEGEN_VERSION_DATE 20210603)
set (CODEGEN_RELEASE_VERSION \"${CODEGEN_VERSION_MAJOR}.${CODEGEN_VERSION_MINOR}.${CODEGEN_VERSION_PATCH}\")
set (CODEGEN_INTERNAL_VERSION \"${CODEGEN_VERSION_MAJOR}.${CODEGEN_VERSION_MINOR}.${CODEGEN_VERSION_PATCH}.${CODEGEN_VERSION_DATE}\")

set(USE_OPENSSL OFF CACHE BOOL "Flag indicating if compile with openssl or not")
#set(USE_CARES OFF CACHE BOOL "Link against libc-ares (rather than rutil/ares) install libcares and/or set LDFLAGS, or use contrib/ares")

# configure a header file to pass some of the CMake settings
# to the source code
configure_file (
  "${PROJECT_SOURCE_DIR}/config.h.in"
  "${PROJECT_BINARY_DIR}/config.h"
)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

set(ARES_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/rutil/ares")
#set(RUTIL_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/rutil")

# MESSAGE(STATUS "CMAKE_INSTALL_PREFIX:" ${CMAKE_INSTALL_PREFIX})
# MESSAGE(STATUS "TARGETS:" ${TARGETS})
# MESSAGE(STATUS "PROJECT_NAME:" ${PROJECT_NAME})
# MESSAGE(STATUS "DESTINATION:" ${DESTINATION})

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
  message(SEND_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()

if(MSVC)
  set(POPT_INCLUDES "${PROJECT_SOURCE_DIR}/popt")
  set(POPT_LIBRARIES popt)
  set(POPT_LFLAGS "")
  add_subdirectory(popt)
else(MSVC)
  find_package(POPT REQUIRED)
endif()

add_subdirectory(rutil)
add_subdirectory(src)
add_subdirectory(test-result)

